/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __IMPL_MGR_H__
#define __IMPL_MGR_H__

namespace xos_http_protocol
{

    class mgr : public i_http_mgr
    {
    public:
        typedef xos::release_impl< mgr > T;

    public:
        mgr();
        ~mgr();

    public:
        static int static_init( xos_container::i_container * pContainer, i_http_mgr ** ppv );
        static xos_container::i_container * container();
        static mgr * get();

    public:
        static int valid_value( const char * lpszKey, const char * lpszStr );
        static int valid_key( const char * lpszStr );
        static int valid_uri( const char * lpszStr );

    public:
        // 
        // html & gz
        // 
        int fmt_simple_html( xos_box::i_string * pHtml, const char * lpszTitle, const char * lpszInfo );
        bool if_need_compress_by_mime( const char * lpszMime, int nSize );
        bool if_need_compress_by_ext( const char * lpszExt, int nSize );
        const char * get_mime_by_ext( const char * lpszExt );

        // 
        // compress
        // 
        int init_compress_type( xos_box::i_list * pTypeList );
        const char * compress_type( const char * lpszType );

        // 
        // content type
        // 
        int init_content_type( xos_box::i_list * pTypeList );
        const char * content_type( const char * lpszFile );

        // 
        // session_impl & cookie_impl callback
        // 
        f_session session_callback( f_session * ppFun );
        f_cookie cookie_callback( f_cookie * ppFun );

        //
        // create object
        //
        i_compose_request* compose_request();
        i_parse_request* parse_request();
        i_compose_return* compose_return();
        i_parse_return* parse_return();

        //
        // 简便创建对象方法
        // 
        http::i_session* session( const char * lpszSessionId );
        http::i_cookie* cookie();

        //
        // heart
        //
        int heart( int interval_ms );

    public:
        int put_back_to_pool();
        int init();
        int term();

    };

} // xos_http_protocol

#endif // __IMPL_MGR_H__
